package com.ruoyi.system.service.impl;


import com.ruoyi.system.domain.SubMajor;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.mapper.SubMajorMapper;
import com.ruoyi.system.service.ISubMajorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SubMajorService implements ISubMajorService {
    @Autowired
    private SubMajorMapper subMajorMapper;

    @Override
    public List<SubMajor> selectSubMajorList(SubMajor major) {
        List<SubMajor> majors = subMajorMapper.selectSubMajorList(major);
        return majors;
    }

    @Override
    public String insertSubMajor(SubMajor major) {
        int i = subMajorMapper.insertSubMajor(major);
        if(i==1){
            return "添加成功";
        }else {
            return "添加失败";
        }

    }

    @Override
    public String deleteSubMajor(List<SubMajor> majors) {
        for (SubMajor major : majors) {
            int i = subMajorMapper.deleteSubMajor(major);
            if(i==0){
                return "删除失败";
            }
        }
        return "删除成功";
    }

    @Override
    public String updateSubMajor(SubMajor major) {
        int i = subMajorMapper.updateSubMajor(major);
        if(i==1){
            return "修改成功";
        }else {
            return "修改失败";
        }
    }

    @Override
    public List<SubMajor> selectPostList(SubMajor major)
    {
        return subMajorMapper.selectPostList(major);
    }


}
